<?php
namespace App\Model;

class UserPay extends Model
{
    // 表名
    protected $table = 'user_pay';
    
    // 保护属性
    protected $guarded = [];
    
    protected $attributes = [
        'shop_id' => 0,
        'code'    => '',
        'full'    => 0,
        'discount'=> 0,
        'status'  => self::STATUS_POST
    ];
    
    protected $dateFormat = 'U';
    
    const STATUS_OK = 1;
    const STATUS_NO = 2;
    const STATUS_POST = 0;
    
    // 用户
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    
    // 店铺
    public function shop()
    {
        return $this->belongsTo(Shop::class, 'shop_id');
    }
}